<template>
  <div class="goods-item" @click="itemClick">
    <img v-lazy="showImg" alt="" @load="imgLoad">
    <div class="goods-info">
      <p>{{ goodsItem.title}}</p>
      <span class="price">{{ goodsItem.price }}</span>
      <span class="collect">{{ goodsItem.cfav }}</span>
    </div>
  </div>
</template>
VueLazyLoad
<script>
export default {
  name:'GoodsListItem',
  props: {
    goodsItem: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  computed: {
    showImg() {
      return this.goodsItem.image || this.goodsItem.show.img
    }
  },
  methods: {
    imgLoad() {
      this.$bus.$emit('itemImgLoad');
    },
    itemClick() {
      this.$router.push('/detail/'+this.goodsItem.iid);
    }
  }
}
</script>

<style scoped>
  .goods-item {
    width: 48%;
    
  }
  .goods-item img {
    width: 100%;
    height: 200px;
  }
  .goods-info {
    text-align: center;
  }
  .goods-info p {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .goods-info .price {
    color: #f40;
    margin-right: 20px;
  }
  .goods-info .collect {
    position: relative;
  }
  .goods-info .collect::before {
    content: "*";
    display: inline-block;
    position: absolute;
    left: -10px;
    top: -1px;
    width: 14px;
    height: 14px;

  }

</style>